package com.zjy.heath_ms.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.zjy.heath_ms.entity.QueryPageBean;
import com.zjy.heath_ms.entity.Result;
import com.zjy.heath_ms.pojo.Member;
import com.zjy.heath_ms.service.MemberService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 项目名 heath_ms
 * 类名  MemberController
 * 作者 lzq
 * 创建时间  2025/5/18 16:24
 */
@RestController
@RequestMapping("/member")
public class MemberController {

    @Autowired
    private MemberService memberService;

    /**
     * 获取会员档案
     * @param queryPageBean
     * @return
     */
    @GetMapping
    public Result getMemberProfiles(QueryPageBean queryPageBean){
        Page<Member> page = memberService.findPage(queryPageBean);
        return Result.buildSuccess(page);
    }

    @PostMapping
    public Result addMemberProfile(@RequestBody Member member){
        memberService.add(member);
        return Result.buildSuccess();
    }
    /**
     * 编辑会员档案
     * @param member
     * @return
     */
    @PutMapping
    public Result editMemberProfile(@RequestBody Member member){
        return Result.buildSuccess(memberService.edit(member));
    }

    /**
     * 删除会员档案
     * @param id
     * @return
     */
    @DeleteMapping
    public Result deleteMemberProfile(Integer id){
        return Result.buildSuccess(memberService.delete(id));
    }

}
